package com.cheyun.netsalev3.view

import android.view.View
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProviders
import com.cheyun.netsalev3.R
import com.cheyun.netsalev3.databinding.ActivityCueTransferBinding
import com.cheyun.netsalev3.utils.BaseActivity
import com.cheyun.netsalev3.utils.InjectorUtils
import com.cheyun.netsalev3.utils.MySharedPreferences
import com.cheyun.netsalev3.viewmodel.CueTransferActivityViewModel

/**
 * 线索移交
 */
class CueTransferActivity : BaseActivity<ActivityCueTransferBinding>() {
    override fun initContentView(): Int {
        return R.layout.activity_cue_transfer
    }

    override fun initViewModel(): ViewModel? {
        var nkey = intent.getStringExtra("nkey")
        if (!nkey.isNullOrBlank()) {
            var t = nkey.split(".")
            if (t.size >= 2) {
                nkey = t[1]
            }
        }
        var level = intent.getStringExtra("level");
        var ids = intent.getStringExtra("ids")
        var factory = InjectorUtils.getCueTransferActivityFactory(nkey, ids,level)
        return ViewModelProviders.of(this, factory).get(CueTransferActivityViewModel::class.java)
    }

    override fun initView() {
    }

    override fun initData() {
        binding.viewModel?.memberInit()
        binding.viewModel?.userTypeInit()
        binding.rlUsertype.visibility = if(MySharedPreferences.getLoginData()?.channel?.isgroup.equals("1")) View.VISIBLE else View.GONE
//
        binding.viewModel?.userTypeId?.observe(this, Observer {
            binding.rlCusLevel.visibility = if(it == 0)  View.VISIBLE else View.GONE
            binding.rlTime.visibility = if(it == 0)  View.VISIBLE else View.GONE
        })

    }


}
